package com.keystudio;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListViewAdapter extends BaseAdapter {
	public List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
	private LayoutInflater inflater;

	public ListViewAdapter(Context context, List<Map<String, Object>> items) {
		this.list = items;
		inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		if (view == null) {
			view = inflater.inflate(R.layout.myshare, null);
		}
		TextView tvId = (TextView) view.findViewById(R.id.itemid);
		TextView tvTitle = (TextView) view.findViewById(R.id.title);
		TextView tvType = (TextView) view.findViewById(R.id.type);
		TextView tvContent = (TextView) view.findViewById(R.id.content);
		tvId.setText((String) list.get(position).get("itemid"));
		tvTitle.setText((String) list.get(position).get("title"));
		tvType.setText((String) list.get(position).get("type"));
		tvContent.setText((String) list.get(position).get("content"));
		return view;
	}
}
